/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.servlet;

import com.qdu.entity.Users;
import com.qdu.service.UserService;
import com.qdu.service.impl.UserServiceImpl;
import java.io.IOException;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.User;

/**
 *
 * @author linnanxiang
 */
@WebServlet("/reg")
public class RegisterUserServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        UserService userService = new UserServiceImpl();
        String uid = req.getParameter("Uid");
        String pwd = req.getParameter("pwd");
        String name=req.getParameter("name");
        String gender = req.getParameter("gender");
        String birthday = req.getParameter("bithday");


        String UIDnum = req.getParameter("UIDnum");
        String email = req.getParameter("email");
        String tel = req.getParameter("tel");
        String city = req.getParameter("city");
        String career = req.getParameter("career");
        Users user = new Users(uid, gender, pwd, birthday, UIDnum, email, tel, city, career, 0, 0, name);

        userService.userRegister(user);
        req.getRequestDispatcher("/Userlogin.html").forward(req, resp);
    }

}
